package com.htthorizon.powersupply.service.impl;

import com.alibaba.druid.util.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.htthorizon.powersupply.domain.ReportLoadMonitor;
import com.htthorizon.powersupply.search.ReportLoadMonitorSearch;
import com.htthorizon.powersupply.service.ReportLoadMonitorService;
import com.htthorizon.powersupply.mapper.ReportLoadMonitorMapper;
import com.htthorizon.powersupply.vo.ReportTgLoadMonitorVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Brilliant
* @description 针对表【report_load_monitor】的数据库操作Service实现
* @createDate 2025-01-19 17:57:40
*/
@Service
public class ReportLoadMonitorServiceImpl extends ServiceImpl<ReportLoadMonitorMapper, ReportLoadMonitor>
    implements ReportLoadMonitorService{

    @Override
    public List<ReportTgLoadMonitorVo> load(ReportLoadMonitorSearch reportLoadMonitorSearch) {
        return baseMapper.load(reportLoadMonitorSearch);
    }

    @Override
    public void loadEdit(ReportTgLoadMonitorVo reportTgLoadMonitorVo) {
        if (StringUtils.isEmpty(reportTgLoadMonitorVo.getDataDt())&& StringUtils.isEmpty(reportTgLoadMonitorVo.getTgNo())){
            throw new RuntimeException("DataDt TgNo数据不能为空");
        }

        ReportLoadMonitor reportLoadMonitor = new ReportLoadMonitor();
        BeanUtils.copyProperties(reportTgLoadMonitorVo, reportLoadMonitor);

        if(reportTgLoadMonitorVo.getRId() == null){
            this.save(reportLoadMonitor);
        }else {
            reportLoadMonitor.setId(Long.parseLong(reportTgLoadMonitorVo.getRId()));
            this.updateById(reportLoadMonitor);
        }
    }
}




